Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

server-destroy

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

server-destroy

Enable destroying a server, and all currently open connections.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
increased by6.86%
Maintainers
1
Weekly downloads
 
Created

What is server-destroy?

The server-destroy npm package provides a simple way to add a destroy method to a Node.js HTTP server, allowing for the immediate termination of all active connections. This is particularly useful for gracefully shutting down servers during development or in production environments.

What are server-destroy's main functionalities?

Add destroy method to server

This feature allows you to add a destroy method to a Node.js HTTP server. The code sample demonstrates how to create an HTTP server, enable the destroy method, and then destroy the server after 5 seconds.

const http = require('http');
const enableDestroy = require('server-destroy');

const server = http.createServer((req, res) => {
  res.end('Hello, world!');
});

// Enable the destroy method on the server
enableDestroy(server);

server.listen(3000, () => {
  console.log('Server is listening on port 3000');
});

// Destroy the server after 5 seconds
setTimeout(() => {
  server.destroy(() => {
    console.log('Server destroyed');
  });
}, 5000);

Other packages similar to server-destroy

FAQs

Package last updated on 20 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc